import express from 'express'
import dbConnect from './db/dbConnect.js'
// import UserModel from './models/userModel.js';
import UserInfoModel from './models/userInfoModel.js'
const app = express()
// 跨域资源共享
import cors from 'cors';
app.use(cors());
const port = 3000
dbConnect()
app.post('/user/getUserList', (req, res) => {
    console.log(req.body)
    UserInfoModel.find({}).then((data) => {
        console.log(data)
        res.status(200).send({
            code: 200,
            data: data || [],
            msg: 'ok',
            total: data.length || 0
        })
    }).catch((err) => {
        console.log(err)
        res.status(500).send({
            code: 500,
            msg: '服务器错误',
        })
    })
})

app.listen(port, () => {
    console.log(`Server is running on http://127.0.0.1:${port}`)
})

